<script>
    $(function($) {
        $('#CoreSiteCosiAuthenticationType').change(function() {
            if($(this).val() == 'Ldap'){
                $('#ldapConfig').slideDown();
            }else{
                $('#ldapConfig').slideUp();
            }
        });
        $('#ldapConfig').hide();
        $('#CoreSiteCosiAuthenticationType').trigger('change');
    });
</script>
<div class="coreSites form">
    <?php echo $this->Form->create('CoreSite'); ?>
    <fieldset>
        <legend><?php echo __('Edit Core Site'); ?></legend>
        <?php
        echo $this->Form->input('id');
        echo $this->Form->input('cosi_name');
        echo $this->Form->input('cosi_desc');
        echo $this->Form->input('cosi_theme', array('type' => 'select', 'options' => $layouts));
        echo $this->Form->input('cosi_url', array('type' => 'url'));
        echo $this->Form->input('cosi_status', array('options' => array('a' => __('Active'), 'i' => __('Inactive')), 'default' => 'a'));
        echo $this->Form->input('cosi_authentication_type', array('options' => array('Core' => __('Core'), 'Ldap' => __('Ldap')), 'default' => 'Core'));
        echo "<div id='ldapConfig'>";
        echo $this->Form->input('cosi_ldap_server', array('placeholder' => 'myldapserver.com or the IP address'));
        echo $this->Form->input('cosi_ldap_rdn', array('placeholder' => 'uid={$user},ou=Users,dc=xxx,dc=xxx'));
        echo "</div>";
        
        ?>
    </fieldset>
    <?php echo $this->Form->end(__('Submit')); ?>
</div>
<div class="actions">
    <h3><?php echo __('Actions'); ?></h3>
    <ul>

        <li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('CoreSite.id')), null, __('Are you sure you want to delete # %s?', $this->Form->value('CoreSite.id'))); ?></li>
        <li><?php echo $this->Html->link(__('List Core Sites'), array('action' => 'index')); ?></li>
    </ul>
</div>
